---@diagnostic disable: undefined-field, unused-local
local cwd = vim.fn.getcwd()

describe("helper.queries", function()
  local assert_eq = assert.is_equal
  local assert_true = assert.is_true
  local assert_false = assert.is_false

  before_each(function()
    vim.api.nvim_command("cd " .. cwd)
  end)

  local queries_helper = require("fzfx.helper.queries")

  describe("[parse_flagged]", function()
    it("parse without flags1", function()
      local results = queries_helper.parse_flagged("asdf")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, nil)
    end)
    it("parse without flags2", function()
      local results = queries_helper.parse_flagged("asdf  ")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, nil)
    end)
    it("parse flags1", function()
      local results = queries_helper.parse_flagged("asdf --")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, "")
    end)
    it("parse flags2", function()
      local results = queries_helper.parse_flagged("asdf --  ")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, "")
    end)
    it("parse flags3", function()
      local results = queries_helper.parse_flagged("asdf --  -w")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, "-w")
    end)
    it("parse flags4", function()
      local results = queries_helper.parse_flagged("asdf --  -w \n")
      assert_eq(type(results), "table")
      assert_eq(results.payload, "asdf")
      assert_eq(results.option, "-w")
    end)
  end)
end)
